Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: time.Since should not be used in defer statement #2014

Conversation

druzn3k
Copy link
Contributor

@druzn3k druzn3k commented Aug 20, 2024

This commit fixes the complaining from go vet about the deferring of time.Since. This can cause wrong time evaluation of the elapsed time. This impact only the debug level, but still it should be addressed.

ref: golang/go#60048

Signed-off-by: Maurizio Del Corno [email protected]

@druzn3k druzn3k force-pushed the fix/make-vet-happy-with-time-since-deferring branch from 5368ded to f5dbf5b Compare August 20, 2024 14:38
@coveralls
Copy link
Collaborator

coveralls commented Aug 20, 2024

Coverage Status

coverage: 89.491% (-0.004%) from 89.495%
when pulling 8a24740 on druzn3k:fix/make-vet-happy-with-time-since-deferring
into c0b6e01 on codenotary:master.

@ostafen
Copy link
Collaborator

ostafen commented Aug 20, 2024

@druzn3k: maybe adding a debug method to immuClient to wrap the call could simplify the code

@druzn3k
Copy link
Contributor Author

druzn3k commented Aug 20, 2024

@druzn3k: maybe adding a debug method to immuClient to wrap the call could simplify the code

Why not :) I'm thinking about something in this ballpark:

func (c *immuClient) debugWithTimeElapsed(msg string, start time.Time)

The name is on the ugly side though, but I can't come up with something better on the spot. Suggestions?

@ostafen
Copy link
Collaborator

ostafen commented Aug 20, 2024

maybe:

func (c *immuClient) debugElapsedTime(method string, start *time.Time)

You could just pass the method name

@druzn3k druzn3k force-pushed the fix/make-vet-happy-with-time-since-deferring branch from f5dbf5b to b9dffb0 Compare August 21, 2024 08:09
@druzn3k
Copy link
Contributor Author

druzn3k commented Aug 21, 2024

done @ostafen . Let me know if you like this version better.

This commit fixes the complaining from `go vet` about the deferring of
`time.Since`. This can cause wrong time evaluation of the elapsed time.
This impact only the debug level, but still it should be addressed.

To make the code a little bit more readable, I wrote a method on the
`immuClient` instance with the signature `debugElapsedTime(method
string, start time.Time)`.

ref: golang/go#60048

Signed-off-by: Maurizio Del Corno <[email protected]>
@druzn3k druzn3k force-pushed the fix/make-vet-happy-with-time-since-deferring branch from b9dffb0 to 8a24740 Compare August 21, 2024 08:19
@ostafen
Copy link
Collaborator

ostafen commented Aug 21, 2024

@druzn3k: looks good to me, thanks!

@ostafen ostafen merged commit bf27080 into codenotary:master Aug 21, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants